// Magic square

# include <iostream>
using namespace std;

class MagicSquare {
  int row, i, j;
  int a[10][10];
public:
  void get();
  void isMagicSquare();
};

void MagicSquare::get() {
  cout << "Enter rows/columns for the matrix: ";
  cin >> row;
  cout << "\n";
  for(i = 0; i < row; i++) {
    for(j = 0; j < row; j++) {
      cout << "Enter element [" << i+1 << ", " << j+1 << "]: " ;
      cin >> a[i][j];
    }
  }
}

void MagicSquare::isMagicSquare() {
  int trace = 0, traceDash = 0;
  for(i = 0; i < row; i++) {
    trace += a[i][i];
  }
  for(i = 0, j = row - 1; i < row; i++, j--) {
    traceDash += a[i][j];
  }
  cout << "Trace: " <<  trace << endl;
  cout << "Trace': " << traceDash << endl;
  cout << ((trace == traceDash) ? "The matrix is magic square!" :  "The matrix is not a magic square!");
}

int main() {
  MagicSquare ms;
  ms.get();
  ms.isMagicSquare();
}
